package com.qf.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.util.Properties;

public enum DBUtils {
    DB;
    private QueryRunner qr;
    DBUtils(){
        try {
            Properties pro =  new Properties();
            //加载配置文件到pro中
            pro.load(DBUtils.class.getResourceAsStream("db.properties"));
            //创建连接池
            DataSource ds = DruidDataSourceFactory.createDataSource(pro);
            //创建数据库操作对象
            qr = new QueryRunner(ds);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public QueryRunner getQr(){
        return qr;
    }
}
